package Day02;

import java.awt.*;
import java.awt.image.BufferedImage;

public class Peep_screen extends Frame {
    BufferedImage img;  //空照片
    public void start() throws AWTException, InterruptedException {
        Robot rb = new Robot();
        Rectangle rt = new Rectangle(0,0,800,800); //构建一个框框，x和y等于0就是从左上角开始，800就是高度和宽度
        img = rb.createScreenCapture(rt);  //利用罗伯特截一个跟上面一样大小的图片
        setSize(800,800);
        setVisible(true);
        for (;;){
            img = rb.createScreenCapture(rt);
            Thread.sleep(100);  //缓冲，显卡遭不住
            repaint();  //重新画，刷新
        }
    }

    @Override
    public void paint(Graphics g) {
        g.drawImage(img,0,0,null); //把图片画出来
    }

    public static void main(String[] args) throws AWTException, InterruptedException {
        new Peep_screen().start();
    }
}
